<script setup name="test">
import calendar from '@/views/calendar.vue';
import {ref} from 'vue';

let list = ref([
    {
        id: 3,
        name: '2023-2024学业考核',
        state: '进行中',
        children: {
            baseWorkSituation: {
                baseWorkId: 10,
                baseWorkName: '2023-2024基础工作',
                baseWorkState: '未提交',
                baseWorkStartTime: '1979-11-20T00:00:00',
                baseWorkEndTime: '2015-07-24T00:00:00',
                operation: '详情'
            },
            academicWorkSituation: {
                academicWorkId: 10,
                academicWorkName: '2023-2024突出工作',
                academicWorkState: '未提交',
                academicWorkStartTime: '2003-06-04T00:00:00',
                academicWorkEndTime: '2019-11-16T00:00:00',
                operation: '详情'
            }
        }
    },
    {
        id: 2,
        name: '2024-2025学业考核',
        state: '进行中',
        children: {
            baseWorkSituation: {
                baseWorkId: 5,
                baseWorkName: '2024-2025基础工作',
                baseWorkState: '未提交',
                baseWorkStartTime: '1979-11-20T00:00:00',
                baseWorkEndTime: '2015-07-24T00:00:00',
                operation: '详情'
            },
            academicWorkSituation: {
                academicWorkId: 5,
                academicWorkName: '2024-2025突出工作',
                academicWorkState: '未提交',
                academicWorkStartTime: '2003-06-04T00:00:00',
                academicWorkEndTime: '2019-11-16T00:00:00',
                operation: '详情'
            }
        }
    }])
let list2 = list.value.map((item) => {
    //获得两个子任务
    const academicWorkSituation = item.children.academicWorkSituation;
    const baseWorkSituation = item.children.baseWorkSituation;
    //将两个子任务合并成对象数组
    const temp = [
        {
            id: academicWorkSituation.academicWorkId,
            name: academicWorkSituation.academicWorkName,
            state: academicWorkSituation.academicWorkState,
            startTime: academicWorkSituation.academicWorkStartTime,
            endTime: academicWorkSituation.academicWorkEndTime,
            operation: '详情'
        },
        {
            id: baseWorkSituation.baseWorkId,
            name: baseWorkSituation.baseWorkName,
            state: baseWorkSituation.baseWorkState,
            startTime: baseWorkSituation.baseWorkStartTime,
            endTime: baseWorkSituation.baseWorkEndTime,
            operation: '详情'
        }
    ];
    //返回合修改后的对象
    return {
        id: item.id,
        name: item.name,
        state: item.state,
        children: temp
    }
})
    console.log(list2);
</script>

<template>
    <div class="test">
        <h1>Test 组件</h1>
        <calendar
        @cancel="cancelSelection"
        @update="updateSelection"
        ></calendar>
    </div>
</template>

<style scoped lang="scss">
</style>